package org.example;


public class Main38 {
    public static void main(String[] args) {
        Integer[] a = {1, 2, 3, 4};
        LinkStackClass<Integer> st = new LinkStackClass<Integer>();
        for (int i = 0; i < a.length; i++) {
            System.out.println("元素" + a[i] + "进栈");
            st.push(a[i]);
        }
        System.out.println("st: " + st.toString());
        System.out.println("逆栈");
        st = Reverse(st);
        System.out.println("st: " + st.toString());
    }


    public static LinkStackClass<Integer> Reverse(LinkStackClass<Integer> st) {
        int[] a = new int[4];
        int i = 0;
        while (!st.empty()){
            a[i]=st.pop();
            i++;
        }
        for (int j = 0;j<i;j++)
            st.push(a[j]);
        return st;
    }
}